<?php


namespace App\Model\CommodityModel;


use App\Model\BaseModel\BaseCommodityModel;
use Service\AppService\IdService;

class StockInfoUserLog extends BaseCommodityModel
{
    public $table = 'stockinfouserlog_s2b';
    
    const  REDUCE   = 1;
    const  RECOVER  = 2;
    const  ADD      = 3;
    const  DELETE   = 4;
    
    /**
     * 写入锁仓库存用户日志
     * @param string $bid
     * @param string $stockId
     * @param int $number
     * @param int $originalNumber
     * @param int $type
     * @return boolean
     */
    public function addUserConsumeLog(string $bid,string $stockId, int $number,int $originalNumber,int $type)
    {
        return $this->insert([
            'ID'            => IdService::instance()->getOtherID(),
            'BuID'          => $bid,
            'StockID'       => $stockId,
            'StockNumber'   => $number,
            'StockOriginalNumber'=>$originalNumber,
            'StockType'     => $type,
            'CreateTime'    => date('Y-m-d H:i:s'),
            'UpdateTime'    => date('Y-m-d H:i:s'),
        ]);
    }
}